<?php

namespace App\Observers;

use App\Models\Good;
use App\Services\ElasticSearch;
use Illuminate\Support\Facades\Log;

class GoodObserver
{
    public function created(Good $good){
        $res=ElasticSearch::getInstance();
        $data=[
            'id'=>$good->id,
            'goods_name'=>$good->goods_name,
            'goods_price'=>$good->goods_price,
            'goods_type'=>$good->goods_type,
            'goods_amount'=>$good->goods_amount,
            'goods_image'=>$good->goods_image,
            'goods_item'=>$good->goods_item,
            'goods_describe'=>$good->goods_describe,
            'goods_status'=>$good->goods_status,
        ];
        $res->create('goods',$good->id,$data,'goods_name');
    }
}
